#ifndef __SPI_LCD_H__
#define __SPI_LCD_H__
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "driver/spi_master.h"
#include "driver/gpio.h"
#include <string.h>
#include <math.h>

#define PIN_NUM_MISO 19
#define PIN_NUM_MOSI 23
#define PIN_NUM_CLK 18
#define PIN_NUM_CS  5
#define PIN_NUM_DC 17
#define PIN_NUM_RST 22
#define PIN_NUM_BCKL 16


#define LCD_HOST VSPI_HOST
#define PARALLEL_LINES 16
#define DMA_CHAN    2


#define WHITE         	 0xFFFF
#define BLACK         	 0x0000	  
#define BLUE           	 0x001F  
#define BRED             0XF81F
#define GRED 			       0XFFE0
#define GBLUE			       0X07FF
#define RED           	 0xF800
#define MAGENTA       	 0xF81F
#define GREEN         	 0x07E0
#define CYAN          	 0x7FFF
#define YELLOW        	 0xFFE0
#define BROWN 			     0XBC40 //棕色
#define BRRED 			     0XFC07 //棕红色
#define GRAY  			     0X8430 //灰色
#define DARKBLUE      	 0X01CF	//深蓝色
#define LIGHTBLUE      	 0X7D7C	//浅蓝色  
#define GRAYBLUE       	 0X5458 //灰蓝色
#define LIGHTGREEN     	 0X841F //浅绿色
#define LGRAY 			     0XC618 //浅灰色(PANNEL),窗体背景色
#define LGRAYBLUE        0XA651 //浅灰蓝色(中间层颜色)
#define LBBLUE           0X2B12 //浅棕蓝色(选择条目的反色)

typedef uint16_t u16 ;
typedef uint8_t u8;


extern spi_device_handle_t spi;
void lcd_spi_pre_transfer_callback(spi_transaction_t *t);
void spi_master_init(void);
void lcd_init(spi_device_handle_t spi);
void lcd_cmd(spi_device_handle_t spi, const uint8_t cmd);
void lcd_data(spi_device_handle_t spi, const uint8_t *data, int len);
void LCD_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color);
void LCD_Address_Set(u16 x1,u16 y1,u16 x2,u16 y2);
void LCD_DrawPoint(u16 x,u16 y,u16 color);
void LCD_WR_DATA(u16 dat);
#endif